package group.igfd.manager.biz.utils;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.InputStream;
import java.net.URL;

public class ImageUtils {

    public static Integer[] getImagesWidthAndHight(String url) {
        Integer[] resultData = new Integer[2];

        try {
            InputStream murl = new URL(url).openStream();
            BufferedImage sourceImg = ImageIO.read(murl);

            resultData[0] = sourceImg.getWidth();
            resultData[1] = sourceImg.getHeight();
            return resultData;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static void main(String[] args) {
        Integer[] imagesWidthAndHight = getImagesWidthAndHight("http://img.igfd.group/img/10532311993237708823792470197545732297.png?x-oss-process=style/def");

        System.out.println("imagesWidthAndHight = " + imagesWidthAndHight[0]);
        System.out.println("imagesWidthAndHight = " + imagesWidthAndHight[1]);
    }
}
